package cuiyt.offer;

import java.util.Stack;

/**
 * @author cyt
 * @create 2020-05-19 16:28
 */
public class T5 {
}

class Solution {
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();

    public void push(int node) {
        stack1.push(node);
    }

    public int pop() throws Exception {
        if (stack2.isEmpty()) {
            // 一定保证 stack2全部出栈的时候在 进栈新元素
            while (!stack1.isEmpty()) {
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();
    }
}
